package com.big.order.listener;

import com.big.common.result.ResultCodeEnum;
import com.big.model.model.order.MerchandiseOrder;
import com.big.order.service.OrderService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *     PAY_TREAT(224, "待支付"),
 *     PAY_THEN(226, "已支付"),
 *     PAY_RUIN(227, "已取消"),
 *     PAY_RUN(220, "支付中"),
 */
@Component
public class MyCancelListener implements ChannelAwareMessageListener {

     @Autowired
     OrderService orderService;

    @Override
    @RabbitListener(queues = "q.dlx" , ackMode = "MANUAL")
    public void onMessage(Message message, Channel channel) throws Exception {
        String orderId = new String(message.getBody());
        System.out.println("取消订单：" + orderId);

        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

}
